package com.foreknow.demo3;

import java.util.Scanner;

public class TestManager {
    public static void main(String[] args) {
        //1. 创建一个Employee类型的数组
        Employee[] employees = new Employee[3];
        //        array1[0] = 12;
        //
        //        int[] array2 = new int[]{1,2,3};
        //
        //        int[] array3 = {12,13,14};

        //2. 向数组中添加3个员工对象
//        Employee e1 = new Employee();
//        e1.setId(100);
//        e1.setName("tom");
//        e1.setSalary(5000);
//        e1.setDept("market");
//        Employee e2 = new Employee();
//        e2.setId(101);
//        e2.setName("fender");
//        e2.setSalary(5000);
//        e2.setDept("market");
//        Employee e3 = new Employee();
//        e3.setId(102);
//        e3.setName("gibson");
//        e3.setSalary(5000);
//        e3.setDept("market");
//
//        employees[0] = e1;
//        employees[1] = e2;
//        employees[2] = e3;

        //循环从控制台录入三次员工信息并将这些信息保存到数组中
        Scanner input = new Scanner(System.in);
        for(int i = 0;i < 3;i++){
            System.out.println("请输入员工编号");
            int id = input.nextInt();
            System.out.println("请输入员工姓名");
            String name = input.next();
            System.out.println("请输入员工工资");
            double salary = input.nextDouble();
            System.out.println("请输入员工部门");
            String dept = input.next();

            Employee e = new Employee(id,name,salary,dept);
            //通过set方法将控制台得到的数据给对象的属性赋值
            //            e.setId(id);
            //            e.setName(name);
            //            e.setSalary(salary);
            //            e.setDept(dept);
            //将对象添加到数组中
            employees[i] = e;
        }

        //3. 遍历数组，输出每个员工的信息
        for(int i = 0;i<employees.length;i++){
            //获取到数组中的元素并赋值给e
            Employee e = employees[i];
            System.out.println(employees[i].getName()+"--"+employees[i].getDept());
            System.out.println(e.getId()+"--"+e.getName()+"--"+e.getSalary()+"--"+e.getDept());
        }
    }
}
